package com.chmingx.JavaBasic.test;

/**
 * 阶乘
 */
public class Factorial {
    public static long fact(long n) {
        if (n < 0) {
            throw new IllegalArgumentException("n must larger than 0!");
        }
        long r = 1;
        for (long i = 1; i <= n; i++) {
            r *= i;
        }
        return r;
    }
}
